package com.wxy.gks.springbootprojectday22practice.config;


import com.wxy.gks.springbootprojectday22practice.web.interceptor.customInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class customConfig  {
    @Bean
    public WebMvcConfigurer webMvcConfigurer() {
        return new WebMvcConfigurer() {
            //添加视图控制
            @Override
            public void addViewControllers(ViewControllerRegistry registry) {
                registry.addViewController("/").setViewName("login");

            }

            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(new customInterceptor())
                        //指定要拦截的请求 /** 表示拦截所有请求
                        .addPathPatterns("/**")

                        .excludePathPatterns("/", "/index.html", "/user/toLogin","/user/login"
                        ,"/getQQCode","/QQLogin","/refreshToken","/jquery-1.11.0.js",
                                "//user/logout"




                        );


            }
        };
    }
}
